<template>
	<!-- showItem:{
		cart:true,
		share:true,
		backTop:true,
	}, -->
	<view class="backTop" v-if="showItem">
		<!-- #ifdef MP-WEIXIN || APP-PLUS || H5 -->
		<view class="fixed-box">
			<!-- 单独分享处理逻辑 -->
			<block v-if="type == 'special'"><image @click.stop="trigger('share')" :src="require('@/common/images/share_icon.png')" /></block>
			<block v-else>
				<button hover-class="btn-hover" class="resetStyle" open-type="share">
					<image v-if="showItem.share" @click.stop="trigger('share')" :src="require('@/common/images/share_icon.png')"  />
				</button>
			</block>
			<image v-if="showItem.backTop" @click.stop="trigger('backTop')" src="@/common/images/backTop.png" />
		</view>
		<!-- #endif -->
	</view>
</template>

<script>
export default {
	props: ['showItem', 'type'],
	data() {
		return {};
	},
	methods: {
		trigger(type) {
			switch (type) {
				case 'cart':
					wx.navigateTo({
						url: '/pages/shopCart/shopCart2'
					});
					break;
				case 'share':
					this.$emit('share');
					break;
				case 'backTop':
					uni.pageScrollTo({
						scrollTop: 0,
						duration: 600
					});
					break;
				default:
					break;
			}
		},
		backTop() {}
	}
};
</script>

<style lang="scss">
.backTop {
	position: fixed;
	bottom: 150rpx;
	right: 20rpx;
	width: 72rpx;
	height: 300rpx;
	z-index: 999;
	text-align: center;

	.fixed-box {
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		height: 100%;
		.resetStyle {
			z-index: 9999;
			background: transparent;
		}

		image {
			width: 72rpx;
			height: 72rpx;
			margin-top: 20rpx;
			// background: #000;
		}
	}
}

.resetStyle::after {
	border: none;
	background: transparent;
}

.btn-hover {
	background: transparent;
}
</style>
